
function getScanWork(){
	queryScan(0,20);
}

//查询扫描工作量
function queryScan(pageNo,pageSize){
	var basePath=$("#basePath").val();
	//var scanMan=$("#scanMan").val();
	var startTime=$("#startTime").val();
	var endTime=$("#endTime").val();
	if((startTime==null || startTime=='') && (endTime==null || endTime=='')){
		layer.alert("查询条件不能为空!", {icon: 0});
		return;
	}
	//如果开始时间和结束时间都选择，要判断结束时间比开始时间大
	if(startTime&&endTime){
		var startDate=new Date(startTime);
		var endDate=new Date(endTime);
		var startDay=startDate.getTime();
		var endDay=endDate.getTime();
		if((endDay-startDay)<0){
			layer.alert("扫描时间的选择范围不正确,请重新选择！", {icon: 0});
			return;
		}
	}
	
	//alert(startTime+"--"+endTime);
	$.ajax({
		type:"post",
		data:{startTime:startTime,endTime:endTime,pageNo:pageNo,pageSize:pageSize},
		url:basePath+"/scan/getScanWorkTotal",
		success:function(data){
			var count= data.count;
			var list=data.list;
			var html="";
			//alert(JSON.stringify(list));
		
			if(list==null || list==''){
				layer.alert("查询数据为空!", {icon: 5});
				$("#tbody").html("");
				$("#currentPage").html("0/0");
				$("#totalPage").html("0");
				$("#page_plus").html("");
				return;
			}else{
				page(pageNo+1,count);
				for(var i=0;i<list.length;i++){
					var workTotal=list[i];
					//alert(workTotal);
					html+="<tr>"+
						  "	<td class='tdLabel_5'>"+(parseInt(i)+1)+"</td>"+
						  "	<td class='tdLabel_5'>"+(workTotal.scanMan==undefined?'':workTotal.scanMan)+"</td>"+
						  "	<td class='tdLabel_5'>"+(workTotal.scanPageCount==undefined?'':workTotal.scanPageCount)+"</td>"+
						  "	<td class='tdLabel_5'>"+(workTotal.totalCopies==undefined?'':workTotal.totalCopies)+"</td>"+
						  "	<td class='tdLabel_5'>"+(workTotal.copiesRate==undefined?'':workTotal.copiesRate)+"</td>"+
						  "	<td class='tdLabel_5'>"+(workTotal.size==undefined?'':workTotal.size)+"</td>"+
						  "	<td class='tdLabel_5'>"+(workTotal.totalCount==undefined?'':workTotal.totalCount)+"</td>"+
						  "	<td class='tdLabel_5'>"+(workTotal.totalCountRate==undefined?'':workTotal.totalCountRate)+"</td>"+
						  "</tr>";
				}
				$("#tbody").html(html);
			}
		}
	})
}


function page(currentPage,totalCounts){
	//var totalCounts = 1000;
    var pageSize = 20;
    var visiblePages = 5;
    //var currentPage = 1;
    /* var totalPages = totalCounts%pageSize==0?(totalCounts/pageSize):(totalCounts/pageSize+1); */
    var totalPages = Math.ceil(totalCounts/pageSize);
    $('#page_plus').jqPaginator({

        totalCounts: totalCounts,
        pageSize:pageSize,
        visiblePages: visiblePages,
        currentPage: currentPage,

        first:'<li class="first"><a href="javascript:void(0);">首页</a></li>',
        prev: '<li class="prev"><a href="javascript:void(0);">上一页</a></li>',
        next: '<li class="next"><a href="javascript:void(0);">下一页</a></li>',
        last: '<li class="last"><a href="javascript:void(0);">末页</a></li>',
        page: '<li class="page"><a href="javascript:void(0);">{{page}}</a></li>',
        onPageChange: function (num,type) {
        	
        	 if(type !='init'){
             
        		 queryScan(num-1,pageSize);
             }
        	
            $("#totalPage").html(totalCounts);
            $("#currentPage").html(num+"/"+totalPages);
        }
    });

}

//导出Excel
function exportExcel(){
	var basePath=$("#basePath").val();
	var startTime=$("#startTime").val();
	var endTime=$("#endTime").val();
	if((startTime==null || startTime=='') && (endTime==null || endTime=='')){
		layer.alert("导出条件不能为空!", {icon: 2});
		return;
	}
	window.location.href=basePath+"/scan/exportExcel?startTime="+startTime+"&endTime="+endTime+"";
}

